<template>
	<view class="board">
		<view class="board-top">
			<image src="https://dy.sykj365.com/uploads/mini/top.png" mode="widthFix"></image>
			<view class="marquee-circle" v-for="(item,index) in marqueeList" :key="item.id">
				<view class="marquee-container marquee-container-top">
					<text class="marquee-content">{{item.title}}</text>
				</view>
			</view>
		</view>
		<view class="withdrawal">
			<view class="withdrawal-circle">
				<image class="activity" src="https://dy.sykj365.com/uploads/mini/activity.png" mode="widthFix"></image>		
				<image src="https://dy.sykj365.com/uploads/mini/withdrawal.png" mode="widthFix"></image>
			</view>
		</view>
		<view class="choose-two-view"> 
			<view class="left-view" ><button open-type="share" style="width: 328rpx;height: 95rpx;opacity: 0;"></button></view>
			<view class="right-view"><button @tap="onShareToTimeline" style="width: 328rpx;height: 95rpx;opacity: 0;"></button></view>
		</view>
		<view class="footer">
			<view class="footer-tabbar">
				<view class="footer-tabbar-title">
					<text @click="getLink">我要提现 ></text>
				</view>
				<view class="footer-tabbar-tab">
					<view class="common" :class="{'active-commom': currentView == 0 }" @click="changeCurrentView(0)">已邀请</view>
					<view class="common" :class="{'active-commom': currentView == 1 }" @click="changeCurrentView(1)">排行榜</view>
				</view>
				<view class="footer-tabbar-content" v-if="currentView == 0">
					<view class="footer-tabbar-content-circle">
						<view class="user-info user-info-odd" v-for="(item, index) in invitationRecords" :key="item.id">
							<view class="user-info-left">
								<img :src="item.avatar_image || 'https://dy.sykj365.com/uploads/mini/user.png'" alt="">
							</view>
							<view class="user-info-center">
								<view class="name">{{item.nickname}}</view>
								<!-- <view class="message"></view> -->
							</view>
							<view class="user-info-right">{{item.create_time}}</view>
						</view>
					</view>
				</view>
				<view class="footer-tabbar-content" v-else>
					<view class="footer-tabbar-content-circle">
						<view class="ranking-title">
							<view>排名</view>
							<view>用户</view>
							<view></view>
							<view>累计收入</view>
						</view>
						<view class="ranking-content" v-for="(item, index) in RankData" :key="item.id">
							<view v-if="index === 0">
								<image src="https://dy.sykj365.com/uploads/mini/first.png" mode="widthFix"></image>
							</view>
							<view v-else-if="index === 1">
								<image src="https://dy.sykj365.com/uploads/mini/second.png" mode="widthFix"></image>
							</view>
							<view v-else-if="index === 2">
								<image src="https://dy.sykj365.com/uploads/mini/third.png" mode="widthFix"></image>
							</view>
							<view v-else>
								{{index+1}}
							</view>
							<view>
								<image :src="item.avatar_image" v-if="item.avatar_image"></image>
								<image src="https://dy.sykj365.com/uploads/mini/user.png" mode="widthFix" v-else></image>
							</view>
							<view>{{item.nickname}}</view>
							<view>{{item.total_price}} 元</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data () {
			return {
				currentView: 0,
				RankData:[],
				invitationRecords: [],
				marqueeList: []
			}
		},
		onLoad (){
			this.getData();
			this.getRankData();
			this.getRecoveryList();
		},
		onShareAppMessage(res) {
			const openid = uni.getStorageSync('openid')
			if (openid) {	
				if (res.from === 'button') {
				  console.log(res.target);
				}
				return {
				  title: '邀请好友奖励3元',
				  path: '/pages/index/index?parentOpenid=' + openid,
				  // imageUrl: 'https://dy.sykj365.com/uploads/mini/fenxiang.png'
				}
			}
		},
		onShareTimeline() {
			return {
			  title: '邀请好友下单打印返10%打印余额',
			  query: ''
			}	
		},
		methods: {
			getLink() {
				getApp().getNavigateTo('/pages/my/withdrawRecords');
			},
			getRecoveryList() {
				this.$http.post(this.$api.recoveryList).then((res) => {
					if(res.code === 20000){
						this.marqueeList = res.data;
					}
				})
			},
			changeCurrentView(data){
				this.currentView = data
			},
			getData() {
				this.$http.get(this.$api.invitationRecord).then((res) => {
					if(res.code === 20000){
						this.invitationRecords = res.data;
					}					
				})
			},
			getRankData() {
				this.$http.get(this.$api.ranking).then((res) => {
					if( res.code == 20000 ) {
						this.RankData = res.data;
					}
				})
			},
		},
	}
</script>

<style lang="less" scoped>
	.board {
		height: 100%;
		background-color: #DDFFFB;
		&-top{
			position: relative;
			overflow: hidden;
			width: 100%;
			height:0;
			padding-bottom: 73.7%;
			image{
				position: absolute;
				right: -55rpx;
				top: -61rpx;
				width: 100%;
			}
		}
		.marquee-circle{
			position: relative;
			// top: 300rpx;
			margin-top: 24rpx;
		}
		.marquee-container {
			width: 100%;
			overflow: hidden;
			white-space: nowrap;
			position: relative;
			animation: marquee 10s linear infinite;
			margin-bottom: 20rpx;
			&-top{
				 animation-delay: 0s; /* 动画延迟10秒开始 */
			}
			&-center{
				 animation-delay: 0s; /* 动画延迟5秒开始 */
			}
			&-footer{
				 animation-delay: 0s; /* 动画延迟0秒开始 */
			}
		}

		.marquee-content {
			display: inline-block;
			// padding-right: 100%; /* 增加一个较长的右侧填充，确保内容足够长以产生滚动效果 */
			background-image: url('https://dy.sykj365.com/uploads/mini/border-radius.png');
			background-size: 100% 100%;
			padding: 10rpx 20rpx;
			font-weight: 400;
			font-size: 24rpx;
			color: #FFFFFF;
			line-height: 44rpx;
		}
	
		@keyframes marquee {
			0% { transform: translateX(-100%); }
			100% { transform: translateX(100%); }
		}
		.withdrawal{
			padding: 0 35rpx;
			&-circle{
				position: relative;
				width: 100%;
				height: 0;
				padding-bottom: 95%;
				image{
					width: 100%;
				}
				.activity{
					position: absolute;
					top: 20rpx;
					right:0;
					width: 175rpx;
				}
			}
		}
		.choose-two-view{
			margin-top: 34rpx;
			display: flex;
			justify-content: space-between;
			padding: 0 35rpx;
			box-sizing: border-box;
			.left-view,.right-view{
				width: 328rpx;
				height: 95rpx;
				background-size: cover; 
			}
			.left-view{
				background-image: url('https://dy.sykj365.com/uploads/mini/invite-friends.png');
			}
			.right-view{
				background-image: url('https://dy.sykj365.com/uploads/mini/share.png');
			}
		}
		.footer{
			margin-top: 50rpx;
			padding: 10rpx;
			&-tabbar{
				border:15rpx solid #F6F6F6;
				border-radius: 30rpx;
				background-color: #B9FCDD;
				&-title{
					height: 88rpx;
					line-height: 148rpx;
					text-align: right;
					text{
						color: #FC4B42;
						font-family: PingFang SC;
						font-weight: 500;
						padding-right: 20rpx;
					}
				}
				&-tab{
					position: relative;
					z-index: 0;
					top: 65rpx;
					display: flex;
					height: 153rpx;
					.common{
						flex: 1;
						font-size: 40rpx;
						color: #FDA700;
						background-image: url('https://dy.sykj365.com/uploads/mini/bg-right.png');
						background-size: 101% 100%;
						text-align: center;
						line-height: 98rpx;
					}
					.active-commom{
						position: relative;
						top: -10rpx;
						flex: 1;
						font-size: 40rpx;
						color: #fff;
						background-image: url('https://dy.sykj365.com/uploads/mini/bg-left.png');
						background-size: 101% 100%;
						text-align: center;
						line-height: 93rpx;
					}
				}
				&-content{
					position: relative;
					padding: 15rpx 3px;
					margin: 0 -10rpx;
					border-radius: 30rpx;
					background-color: rgba(255,255,255,.3);
					border: 1px solid #fff;
					box-sizing: border-box;
					&-circle{
						width: 100%;
						height: auto;
						background-color: #F2FCE6;
						border-radius: 30rpx;
						padding: 60rpx 35rpx 40rpx 35rpx;
						box-sizing: border-box;
						.user-info{
							display: flex;
							align-items: center;
							width: 100%;
							padding: 30rpx;
							border-radius: 30rpx;
							box-sizing: border-box;
							margin-bottom: 20rpx;
							&-odd{
								background-color: #DDFFF5;
							}
							&-even{
								background-color: rgba(225, 242, 255, 1);
							}
							&-left{
								width: 93rpx;
								height: 93rpx;
								img{
									width: 100%;
									height: 100%;
								}
							}
							&-center{
								flex: 1;
								min-width: 0;
								padding: 0 15rpx;
								box-sizing: border-box;
								.name{
									font-weight: 500;
									font-size: 31rpx;
									color: #433939;
									white-space: nowrap;
									overflow: hidden;
									text-overflow: ellipsis;
								}
								.message{
									font-weight: 400;
									font-size: 25rpx;
									color: #909090;
									line-height: 40rpx;
									white-space: nowrap;
									overflow: hidden;
									text-overflow: ellipsis;
								}
							}
							&-right{
								width: 230rpx;
								font-family: Source Han Sans SC;
								font-weight: 400;
								font-size: 28rpx;
								color: #999999;
							}
						}
						.ranking-title{
							display: flex;
							height: 46rpx;
							line-height: 46rpx;
							view:nth-child(1){
								width: 100rpx;
								font-weight: 400;
								font-size: 28rpx;
								color: #666666;
								text-align: center;
							}
							view:nth-child(2){
								width: 100rpx;
								font-weight: 400;
								font-size: 28rpx;
								color: #666666;
								text-align: center;
							}
							view:nth-child(3){
								flex: 1;
							}
							view:nth-child(4){
								width: 200rpx;
								font-weight: 400;
								font-size: 28rpx;
								color: #666666;
								text-align: center;
							}
						}
						.ranking-content{
							display: flex;
							align-items: center;
							height: 126rpx;
							view:nth-child(1){
								width: 100rpx;
								display: flex;
								justify-content: center;
								font-weight: 500;
								font-size: 29rpx;
								color: #333333;
								image{
									width: 38rpx;
								}
							}
							view:nth-child(2){
								width: 100rpx;
								display: flex;
								justify-content: center;
								image{
									width: 60rpx;
									height: 60rpx;
									border-radius:50%;
								}
							}
							view:nth-child(3){
								flex: 1;
								font-weight: 400;
								font-size: 29rpx;
								color: #000000;
								overflow: hidden;
								white-space: nowrap;
								text-overflow: ellipsis;
							}
							view:nth-child(4){
								width: 180rpx;
								text-align: center;
								font-weight: 500;
								font-size: 29rpx;
								color: #FF5700;
							}
						}
					}
				}
			}
		}
	}
</style>